/*
 * @Description:
 * @Author: zhaolei
 * @Date: 2023-05-25 15:10:40
 */
import {
  REDEMPTION_TYPE_LIST,
  REDEMPTION_TYPE,
  REDEMPTION_STATUS,
  REDEMPTION_STATUS_LIST,
} from '@/const/type';
export const formOption = (flag = false, type) => {
  return {
    ...window.$crudMixins.tableOptions,
    detail: flag,
    menuPosition: 'right',
    submitBtn: false,
    emptyBtn: false,
    labelWidth: 120,
    labelPosition: 'left',
    column: [
      {
        label: '兑换券类型',
        prop: 'type',
        type: 'radio',
        row: true,
        dicData: REDEMPTION_TYPE_LIST,
        rules: [
          {
            required: true,
            message: '兑换券类型',
          },
        ],
      },
      {
        label: '兑换物编号',
        prop: 'ids',
        row: true,
        type: 'select',
        multiple: true,
        filterable: true,
        dicQuery: {
          type: type,
        },
        clearable: true,
        dicUrl: '/shop-activity/coupons/activity/list',
        props: {
          label: 'code',
          value: 'id',
        },
        typeformat(item, label, value) {
          return `${item.code}（${item.name}）`;
        },
        rules: [
          {
            required: true,
            message: '请选择兑换物编号',
          },
        ],
      },
      {
        label: '兑换物名称',
        prop: 'name',
        row: true,
        rules: [
          {
            required: true,
            message: '请输入兑换物名称',
          },
          {
            min: 1,
            max: 30,
            message: '长度不能超过30个字符',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '兑换使用罐头能量值',
        require: true,
        prop: 'needNumber',
        type: 'number',
        value: 0,
        row: true,
        labelWidth: 150,
        precision: 0,
        min: 0,
        max: 99999999,
        labelTip: '每个宠物每次兑换所需罐头能量值',
        rules: [
          {
            message: '请输入兑换使用罐头能量值',
            required: true,
          },
        ],
      },
      {
        require: true,
        label: '月兑换次数限制',
        labelTip: '每个宠物每个月最高可兑换次数',
        prop: 'monthNumber',
        precision: 0,
        value: 0,
        type: 'number',
        labelWidth: 150,
        row: true,
        min: 0,
        max:99999999,
        rules: [
          {
            message: '请输入月兑换次限制',
            required: true,
          },
        ],
      },
      {
        label: '兑换物图片',
        display: true,
        prop: 'files',
        type: 'upload',
        listType: 'picture-card',
        fileSize: 10 * 1024,
        fileType: 'img', //img/video/audio
        propsHttp: {
          name: 'hash',
          url: 'key',
        },
        multiple: true,
        oss: 'qiniu',
        cropperOption: {
          // autoCropWidth: 187.5,
          // autoCropHeight: 250,
          enlarge: 2,
          fixed: true,
          fixedNumber: [1, 1], // 截图框的宽高比例
        },
        tip: '请上传jpg/png/jpeg/webp/heic类型的文件，且大小不超过10M，最多可上传10张图片,推荐尺寸为800*800',
        row: true,
        span: 24,
        limit: 10,
        accept: '.jpg,.png,.jpeg,.webp,.heic',
        rules: [{ required: true, message: '请上传兑换图片', trigger: 'blur' }],
      },
      {
        label: '使用规则',
        prop: 'rule',
        type: 'textarea',
        maxlength: 2000,
        span: 24,
        row: true,
        showWordLimit: true,
        autosize: true,
        rules: [{ required: true, message: '请输入使用规则', trigger: 'blur' }],
      },
      {
        label: '状态',
        prop: 'status',
        span: 24,
        type: 'select',
        dicData: REDEMPTION_STATUS_LIST,
        display: flag,
      },
    ],
  };
};
